library(readxl)
## Warning: package 'readxl' was built under R version 4.1.3
library(ggplot2)
library(ggiraph)
## Warning: package 'ggiraph' was built under R version 4.1.3
library(patchwork)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
X <-read_excel("C:/Users/Xinyue Zhan/Desktop/data.xlsx",sheet=1)
p <- ggplot(data = X,
mapping = aes(x = dose, y = infection.rate, color=agent.strain)) +
geom_point(size = 2)+
scale_x_log10(labels = scales::comma) +
geom_line()+
theme_minimal()+ #make the data frame white
labs(title = "Probability of infection among various STEC",
x= "amount of dose",
y="probability",
color = "agent strain")
ggplotly(p)
p2 <- ggplot(X, aes(x=agent.strain, y=exposure, fill=agent.strain)) +
geom_bar(stat = "identity") + theme_bw() +
labs( title="number of data",
y= "agent strain",
x= "number of exposure cases") +
coord_flip() #help to solve the issue of text overlapping each other
ggplotly(p2)